package com.创建方式三实现Callable接口;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable();

        //把他封装成任务对象 FutureTask 是实现Runnable接口的 所有用它来封装Callable接口
        //用他来得到返回结果
        FutureTask<String> stringFutureTask = new FutureTask<String>(myCallable);

        //封装成线程对象
        new Thread(stringFutureTask).start();

        //拿到结果对象
        System.out.println(stringFutureTask.get());
    }
}
